package com.ss.android.caijing.stepcounter;

import android.Manifest;
import android.content.Context;

import com.ss.android.caijing.stepcounter.permission.PermissionCheckHelper;
import com.ss.android.caijing.stepcounterlib.log.AccelerateLog;
import com.ss.android.caijing.stepcounterlib.log.CodeLog;
import com.ss.android.caijing.stepcounterlib.log.SSLog;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by zdh on 2017/11/10.
 */

public class TestClass {
    private static String TAG = "TestClass";
    public static void testDate(){
        Date date = new Date(System.currentTimeMillis());
        SSLog.i(TAG,"date:"+date.getTime());
        SSLog.i(TAG,"format short:"+SimpleDateFormat.getDateInstance(DateFormat.SHORT).format(date));
        try {
            date = SimpleDateFormat.getDateInstance().parse(SimpleDateFormat.getDateInstance().format(date));
            SSLog.i(TAG,"modify date:"+date.getTime());
        }catch (Exception ex){

        }

    }

    public static void testLocalLog(){
        CodeLog.e("e test","testLocalLog");
        SSLog.i(TAG,"date:"+"testLocalLog");

        CodeLog.i("i test","testLocalLog");
        SSLog.i(TAG,"date:"+"testLocalLog");
    }

    public static void startAccelateLog(final Context context){
        if (!PermissionCheckHelper.isPermissionGranted(context, Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
            String[] requestArray = {Manifest.permission.WRITE_EXTERNAL_STORAGE,Manifest.permission.READ_EXTERNAL_STORAGE};
            String[] messages = {"",""};
            PermissionCheckHelper.instance().requestPermissions(context, 0, requestArray, messages, new PermissionCheckHelper.PermissionCallbackListener() {
                @Override
                public void onPermissionCheckCallback(int requestCode, String[] permissions, int[] grantResults) {
                    AccelerateLog.instance().initLogFile(context);
                }
            });
        }
        AccelerateLog.instance().initLogFile(context);

    }

}
